﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Hockey.Shared;
using Hockey.UILayer.ViewModels;
using Microsoft.Practices.Prism.Events;

namespace Hockey.UILayer.Forms
{
    /// <summary>
    /// Interaction logic for NewGameForm.xaml
    /// </summary>
    public partial class NewGameForm : Window
    {
        private IEventAggregator _events;

        public NewGameForm(IEventAggregator events)
        {
            InitializeComponent();

            if (events == null)
                throw new ArgumentNullException("Events");
            _events = events;

            // register event to close the form
            _events.GetEvent<CloseForm>().Subscribe((obj) =>
            {
                if (obj == this.DataContext)
                {
                    Close();
                }
            }, true);
        }
    }
}
